﻿@model DataInfo<AdmColUpdateModel>
@{
    AdmColUpdateModel mymodel = new AdmColUpdateModel();
    var operstr = new string[] { "确认修改", "添加" };
    ViewBag.operi = 1;
    if (Model.Success && Model.Data.ID > 0)
    {
        ViewBag.operi = 0;
    }
    ViewBag.Title = "操作-" + operstr[ViewBag.operi];
        //Layout = "~/Views/Shared/_Blank_Js.cshtml";
    
}
<style>
    .form-horizontal .control-group
    {
        margin-bottom: 10px;
    }
</style>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script type="text/javascript">
    function Submit_Opear() {
        if (!window.IsValid) {
            console.log("值没有更新");
            return false;
        }
        var form = $(".form-horizontal"),
            url = form.attr('action'),
            pdata = form.serialize();
        $.validator.unobtrusive.parse(form);
        form.validate();
        var errorList = form.validate().errorList;
        if (errorList.length < 1) {
            $.post(url, pdata,
                function (data) {
                    alert(data.Message);
                }, "json");
        } else {
            var html = "";
            $.each(errorList, function (index, error) {
                html += error.message + ".";
            });
            alert(html);
        }
        window.IsValid = false;
        return false;
    }
</script>
<div id="MyOpearTarger">
    <div class="row" style="height: 500px; width: 550px; overflow-y: auto; overflow-x: hidden">
        <div class="span12">
            <br />
            @using (Html.BeginForm("Opear", "AdmCol", FormMethod.Post, new { @class = "form-horizontal", onsubmit = "return Submit_Opear();", oppri = ViewBag.operi }))
            {
                @Html.HiddenFor(p => p.Data.ID)
                <div id="debug" class="">
                    @Html.ValidationSummary(true)
                </div>
                @Html.Niko_HT_Input_Text(p => p.Data.Name)
                @Html.Niko_HT_Input_Text(p => p.Data.Url)
                @Html.Niko_HT_Input_Text(p => p.Data.SmallClass)
                @Html.Niko_HT_Input_Number(p => p.Data.ClassLevel)
                @Html.Niko_HT_Input_Number(p => p.Data.OrderBy)
                @Html.Niko_HT_Radio(p => p.Data.IsOpenWin)
                @Html.Niko_DropDown(p => p.Data.AdmColID, DAL.Enums.emAdmRole.BaseItems, (byte)Model.Data.AdmColID)
                <div class="control-group">
                    <!-- Button -->
                    <div class="controls">
                        <button class="btn btn-success" data-loading-text="加载中...">
                            @operstr[ViewBag.operi]
                        </button>
                    </div>
                </div>
            }
        </div>
    </div>
</div>
